package com.dao.impl;

import com.dao.FileDao;
import com.domain.FileClass;
import com.factory.OfficeFactory;

import java.util.ArrayList;

public class FileDaoImpl implements FileDao {

    @Override
    public Boolean save(FileClass file) {
        String sql = "insert into file_management values(?,?,?,?)";

        return OfficeFactory.update(sql,file.getFile_id(),file.getFile_type(),file.getFile_name(),
                file.getFile_location());
    }

    @Override
    public Boolean delete(String uuid) {
        String sql = "delete from file_management where file_id = ?";

        return OfficeFactory.update(sql,uuid);
    }

    @Override
    public ArrayList<FileClass> select() {
        String sql = "select * from file_management";

        return OfficeFactory.select(new FileClass(), sql);
    }

    @Override
    public Boolean update(FileClass file) {
        String sql = "update file_management set file_type = ? , file_name = ? , file_location = ? where file_id = ?";

        return OfficeFactory.update(sql,file.getFile_type(),file.getFile_name(),file.getFile_location(),file.getFile_id());
    }
}
